//
// Created by 刘洋 on 2024/2/13.
//

#ifndef __PID_H
#define __PID_H
#include "time_utils.h"
#include "foc_utils.h"
typedef struct
{
    float error_prev; //!< last tracking error value
    float output_prev;  //!< last pid output value
    float integral_prev; //!< last integral component value
    unsigned long timestamp_prev; //!< Last execution timestamp
    float P; //!< Proportional gain
    float I; //!< Integral gain
    float D; //!< Derivative gain
    float output_ramp; //!< Maximum speed of change of the output value
    float limit; //!< Maximum output value
}PID;
float PIDControllerInit(PID *pid, float P, float I, float D, float ramp, float limit);
float PIDController(PID *pid, float error);
#endif //__PID_H
